package com.bupt.basic;

import com.bupt.utils.GenerateIDUtils;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.util.*;

@EqualsAndHashCode
@Data
public class Project implements Serializable {
    private static final long serialVersionUID = 1905975949805525226L;
    private String id;//项目id
    private String name;//项目名字
    private String path;//项目位置
    private boolean isPlanned;//是否规划过
    private List<Double> portUtilization=new ArrayList<>();//存储历次规划的端口利用率,最后的为最新
    private Integer[] portNums=new Integer[4];//存储最新一次规划的四种端口类型
    //private List<Double> serviceRecoveryRate = new ArrayList<>();//存储历次抗毁的业务恢复率，最后的为最新,保留两位小数
/*    private List<IBasicNetWork.BasicLink> fiberLinks = new ArrayList<>();
    private Set<IBasicNetWork.BasicLink> linkSet=new HashSet<>();
    private List<IBasicNetWork.BasicLink> wdmLinks = new ArrayList<>();
    private List<IBasicNetWork.BasicLink> otnLinks = new ArrayList<>();
    private List<IBasicNetWork.BasicLink> sdhLinks = new ArrayList<>();*/
  /*  private List<IBasicNetWork> satellites = new ArrayList<>();
    private List<IBasicNetWork> shortWaves = new ArrayList<>();*/
   // private List<IBasicNetWork.BasicNode> commonNodes = new ArrayList<>();
    private List<DemandReportService> demandList=new ArrayList<>();

    //当前网络
    private BasicNetWork basicNetWork;

    private Set<IBasicNetWork.BasicNode> commonNodeSet=new HashSet<>();

    public void setPlanned(boolean planned) {
        isPlanned = planned;
    }

    public Project(String id, String name, String path) {
        this.id = id;
        this.name = name;
        this.path = path;
        this.basicNetWork= new BasicNetWork(GenerateIDUtils.generateIdStr(), new Date());
    }

    public IBasicNetWork.BasicNode searchNodeById(String id) {
        if (null == id){
            return null;
        }
        List<IBasicNetWork.BasicNode> nodeList = basicNetWork.getNodeList();
        for (IBasicNetWork.BasicNode node : nodeList) {
            if (node.getNodeId().equals(id)) {
                return node;
            }
        }
        return null;
        }

    public BasicNetWork getNetWork() {
        if (null == basicNetWork) {
            basicNetWork.checkCurrentNetWork();
        }
        return basicNetWork;
    }




    //添加链路 失败返回false
 /*   public boolean addLink(IBasicNetWork.BasicLink link) {
        if (linkSet.add(link)) {
            if (link instanceof IBasicNetWork.FiberLink) {
                fiberLinks.add((IBasicNetWork.FiberLink) link);
                return true;
            } else if (link instanceof IBasicNetWork.WdmLink) {
                wdmLinks.add((IBasicNetWork.WdmLink) link);
                return true;
            } else if (link instanceof IBasicNetWork.OtnLink) {
                otnLinks.add((IBasicNetWork.OtnLink) link);
                return true;
            } else if (link instanceof IBasicNetWork.SdhLink) {
                sdhLinks.add((IBasicNetWork.SdhLink) link);
                return true;
            } else {
                return false;
            }
        }
        return false;
    }*/



}
